package rtmp;

import util.Common;
import lombok.Getter;
import lombok.Setter;
import org.apache.log4j.Logger;

import java.util.Arrays;

/**
 * rtmp chunkSize 设置
 */
public class RtmpChunkSize extends Amf {

    private final static Logger logger = Logger.getLogger(RtmpChunkSize.class);

    @Setter
    @Getter
    private int chunkSize;

    public void parseChunkSize(byte[] messageData) {
        logger.info("chunksize");
         setAmfClass(messageData);
         logger.info(amfClass.pos + 4  + " === " + amfClass.message.length);
        if (amfClass.pos + 4 > amfClass.message.length) {
            logger.info("数据不足");
//            chunkSize = Common.DEFAULT_CHUNK_MESSAGE_LENGTH;
            return;
        }
        chunkSize = Common.byteToInt(Arrays.copyOfRange(amfClass.message, amfClass.pos, amfClass.pos + 4));
        logger.info(chunkSize);
    }


}
